﻿using DAL;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
namespace BLL
{
   public class StoreMarager
    {
        StoreService service = new StoreService();
        //商家表操作
        //新增商家
        public bool AddStore(Store store ) 
        {
            return service.Addstore(store);
        }
        //查询全部店家
        public List<Store> SumStore() 
        {
            List<Store> stores = new List<Store>();
            Store store = null;
            SqlDataReader reader = service.SumStore();
            while (reader.Read())
            {
                stores.Add(store = new Store
                    (
                      reader.GetInt32(0),
                    reader.GetString(1)
                    ));
              
            }
            DBhelper.Close();
            return stores;
        }
        public List<Store> StoreCount()
        {
            List<Store> Cailist = new List<Store>();
            Store product = null;
            SqlDataReader reader = service.StoreType();
            while (reader.Read())
            {
                product = new Store(
                      reader.GetInt32(0),
                    reader.GetString(1)

                   );
                Cailist.Add(product);
            }
            reader.Close();
            return Cailist;
        }
    }
}
